<?php

namespace catchAdmin\phone\controller;

use catcher\base\CatchController;
use EasyWeChat\Factory;
class Mini extends CatchController
{
    public function index($code,$iv,$encryptedData){
        $config = [
            'app_id' => 'wx54ddfd59d0a80d2a',
            'secret' => 'a4f36a65698f3ca5f551ba23dcb3f891',
            // 下面为可选项
            // 指定 API 调用返回结果的类型：array(default)/collection/object/raw/自定义类名
            'response_type' => 'array',
//
//            'log' => [
//                'level' => 'debug',
//                'file' => __DIR__.'/wechat.log',
//            ],
        ];
        $app = Factory::miniProgram($config);
        $info = $app->auth->session($code);
        p($info);
        $decryptedData = $app->encryptor->decryptData($info['session_key'], $iv, $encryptedData);
        p($decryptedData);
    }
}